#coding=utf-8
'''
Created on 2017-6-15

@author: sandy
'''
import json
import os
from pycommon import utils, remotemanager

class ProxyConfig(object):
    
    def __init__(self):
        self.rundir = os.path.dirname(__file__)
        self.proxy_ip = u""
        self.proxy_port = 0
        self.server_ip = u""
        self.server_port = 0
        self.max_client = 100
        self.timeout = 0
    
    def loadFromFile(self):
        cf = json.load(file(os.path.join(self.rundir,"serverconfig.json")), encoding='utf-8')
        self.loadFromJson(cf)
        
    def loadFromJson(self, cf):
        self.proxy_ip = cf.get("proxy_ip")
        self.proxy_port = cf.get("proxy_port")
        self.server_ip = cf.get("server_ip")
        self.server_port = cf.get("server_port")
        self.max_client = cf.get("max_client")
        self.timeout = cf.get("timeout")

instance = ProxyConfig()